import { Inject, Injectable } from '@nestjs/common';
import { CreateZiliaoDto } from './dto/create-ziliao.dto';
import { UpdateZiliaoDto } from './dto/update-ziliao.dto';
import { Ziliao } from './entities/ziliao.entity';
import { Repository } from 'typeorm';

@Injectable()
export class ZiliaoService {
  constructor(
    @Inject('ZILIAO_REPOSITORY')
    private ziLiaoRepository: Repository<Ziliao>,
  ) {}
  create(createZiliaoDto: CreateZiliaoDto) {
    const ziliao = this.ziLiaoRepository.create(createZiliaoDto);
    return this.ziLiaoRepository.save(ziliao);
  }

  findAll() {
    return this.ziLiaoRepository.find();
  }

  findOne(id: number) {
    return this.ziLiaoRepository.findOne({ where: { id: id } });
  }

  update(id: number, updateZiliaoDto: UpdateZiliaoDto) {
    return this.ziLiaoRepository.update(id, { ...updateZiliaoDto });
  }

  remove(id: number) {
    return this.ziLiaoRepository.delete(id);
  }
}
